package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.WebVisitMapper;

import com.itheima.pojo.WebVisit;
import com.itheima.pojo.WebVisitVO;
import com.itheima.service.WebVisitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

@Service
public class WebVisitServiceImpl implements WebVisitService {

    @Autowired
    private WebVisitMapper webVisitMapper;

    @Override
    public Page<WebVisit> getList(WebVisitVO webVisitVO) {

        //分页条件查询
        PageHelper.startPage(webVisitVO.getCurrentPage(), webVisitVO.getPageSize());

        Example example = new Example(WebVisit.class);
        Example.Criteria criteria = example.createCriteria();
        if (webVisitVO.getKeyword() != null && !"".equals(webVisitVO.getKeyword())) {
            criteria.andEqualTo("otherData", webVisitVO.getKeyword());
        }
        //返回结果
       return  (Page<WebVisit>) webVisitMapper.selectByExample(example);
    }
}
